<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>定时任务</title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge" >
	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <script src="${g_path}/js/sys/common.js" type="text/javascript"></script>
	<style type="text/css">
	    body,html {
			width: 100%;
			height: 100%;
			padding: 0px;
			margin: 0px;
			overflow: hidden;
		}    
	</style>  

  </head>
  <body>
  	<div class="mini-toolbar" style="padding:0px;border-bottom:0;">
        <table style="width:100%;">
            <tr>
            <td style="width:100%;">
                <a class="mini-button" iconCls="icon-add" plain="true" onclick="add();">新增</a>
                <a class="mini-button" iconCls="icon-remove" plain="true" onclick="del();">删除</a>
                <span class="separator"></span>
                <a class="mini-button" iconCls="icon-save" plain="true" onclick="save();">保存</a>
            </td>
            <td style="white-space:nowrap;">
                <input id="txtKey" class="mini-textbox" emptyText="请输入关键字"  onenter="onSearch()" />
                <a class="mini-button" iconCls="icon-search" plain="true" onclick="onSearch()">查询</a>
                </td>
            </tr>
        </table>
    </div>
    <!--撑满页面-->
    <div class="mini-fit" >

        <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" fitColumns="false"
            url="${g_path}/task/list"  idField="id" sizeList="[30,50,100,500]" pageSize="50"
            allowCellEdit="true" allowCellSelect="true" multiSelect="true"
        >
            <div property="columns">
                <div type="checkcolumn" ></div>
                <div type="indexcolumn" ></div>
                <div field="taskname" width="200" vtype="required" headerAlign="center" align="center" allowSort="false">任务名称
                    <input property="editor" class="mini-textbox" style="width: 100%;" />
                </div> 
                <div field="exp" width="200" vtype="required" headerAlign="center" align="center" allowSort="false">Cron表达式
                    <input property="editor" class="mini-textbox" style="width: 100%;" />
                </div> 
                <div field="class" width="200" vtype="required" headerAlign="center" align="center" allowSort="false">实现类
                    <input property="editor" class="mini-textbox" style="width: 100%;" />
                </div>
                <div field="status" type="checkboxcolumn" trueValue="1" falseValue="0"  width="120" headerAlign="center" align="center" allowSort="false">是否启用
                    
                </div>                      
            </div>
        </div> 

    </div>
</body>
</html>
<script type="text/javascript">
    mini.parse();
    var grid = mini.get("datagrid1");
	onSearch();

    function add() {
        var newRow = {status:'1'};
        grid.addRow(newRow);
        grid.scrollIntoView(newRow);
    }

    function del() {
        var rows = grid.getSelecteds();
        if (rows.length < 1) {
            MsgBox.alert("请勾选需要删除的数据！");
            return;
        }
        grid.removeRows(rows);
    }

    function save() {
        grid.commitEdit();
        grid.validate();
        if (grid.isValid() == false) {
            var error = grid.getCellErrors()[0];
            grid.beginEditCell(error.record, error.column);
            return;
        }

        var datas = grid.getChanges(null, true);
        var json = mini.encode(datas);

        var url = "${g_path}/task/save";
        var re = getJson(url, { data: json }, true, function (re) {
            if (!re.isOk) {
                MsgBox.alert("保存失败！");
            }
            else {
                MsgBox.alert("保存成功！");
                onSearch();
            }
        });
    }

    function onSearch() {
        var param = {
            key: mini.get("txtKey").getValue()
        }

        grid.load(param);
    }

</script>
